package ast;

import out.Out;
import mem.interfaces.IMem;
import environnement.interfaces.IEnv;
import exceptions.LogoException;
import ast.interfaces.IAST;
import ast.interfaces.IASTmult;

public class ASTmult implements IASTmult{
	private IAST op1;
	private IAST op2;
	
	public ASTmult(IAST op1,IAST op2){
		this.op1 = op1;
		this.op2 = op2;
	}

	public IAST getOp1() {
		return op1;
	}

	public void setOp1(IAST op1) {
		this.op1 = op1;
	}

	public IAST getOp2() {
		return op2;
	}

	public void setOp2(IAST op2) {
		this.op2 = op2;
	}

	@Override
	public Float eval(Out o, IEnv e, IMem m) throws LogoException{
		return ((Float)getOp1().eval(o, e, m)) * ((Float)getOp2().eval(o, e, m));
	}

	@Override
	public String toTreeString(String ident,IEnv env,IMem mem) {
		return getOp1().toTreeString(ident,env,mem) + '*' + getOp2().toTreeString(ident,env,mem);
	}
}
